package com.study.designPattern.create.singleton;

/**
 * @author ysy
 * @version 1.0
 * @Title: StaticInnerClassSingleton
 * @Note <b>ProjectName:</b> Pre-research
 * <br><b>PackageName:</b> com.study.designPattern.create.singleton
 * <br><b>ClassName:</b>
 * <br><b>Date:</b>

 */
public class StaticInnerClassSingleton {

    // 静态内部类
    private static class SingletonHolder {
        // 对象通过final Static修饰
        private static final StaticInnerClassSingleton INSTANCE = new StaticInnerClassSingleton();
    }

    public static StaticInnerClassSingleton getInstance(){
       return  SingletonHolder.INSTANCE;
    }

    public StaticInnerClassSingleton() {
    }

    private String name;
    private Integer age;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public void whoAreU(String name, Integer age){
        System.out.println("my name is" + name + ", i am " + age + "years old!!");
    }
}
